<?php

use Phinx\Migration\AbstractMigration;

class CreateBusinessPartnerProduct extends AbstractMigration
{
    public function change()
    {
        $table = $this->table('business_partner_product');
        $table->addColumn('partner_id', 'integer', ['comment' => '商家ID'])
            ->addColumn('product_id', 'integer', ['comment' => '产品ID'])
            ->addColumn('price', 'decimal', ['precision' => 12, 'scale' => 2, 'default' => '0.00', 'comment' => '商家价格'])
            ->addColumn('market_price', 'decimal', ['precision' => 12, 'scale' => 2, 'default' => '0.00', 'comment' => '市场价'])
            ->addColumn('stock', 'integer', ['default' => 0, 'comment' => '库存'])
            ->addColumn('sales', 'integer', ['default' => 0, 'comment' => '销量'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态：0=下架，1=上架'])
            ->addColumn('sort', 'integer', ['default' => 0, 'comment' => '排序'])
            ->addColumn('created_at', 'timestamp', ['null' => true])
            ->addColumn('updated_at', 'timestamp', ['null' => true])
            ->addIndex(['partner_id'])
            ->addIndex(['product_id'])
            ->addIndex(['status'])
            ->create();
    }
} 